<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
	</head>
	<body>
		请求到的数据内容：<span></span> <br>
		<button type="button" onclick="fun()">请求数据</button>
		
		<script type="text/javascript">
			function fun(){
				//1. 创建对象
				var xhr = new XMLHttpRequest();
				//2. 创建请求
				xhr.open("get","data.txt",false);//fasle同步请求
				//3. 发送请求
				xhr.send();
				//4. 处理响应
				var str = xhr.responseText;
				document.querySelector("span").innerHTML=str;				
			}
		</script>
		
	</body>
</html>
